<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so layui-form-pane" action="para/updateRate" method="post">
        	  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">利率信息</label>
    <div class="layui-input-block">
      <textarea name="rates" id="rates" placeholder="请输入内容" class="layui-textarea">${rates!}</textarea>
    </div>
  </div>
            
          <button class="layui-btn"      lay-submit="false" lay-filter="modify"><i class="layui-icon"></i>修改</button>
        </form>
      </div> 
      <blockquote style="font-size: 30px;" class="layui-elem-field">请使用花括号{}的方式，key表示利率，name表示利率的文字说明，花括号前必须有逗号隔开</blockquote>

    </div>
    <script>
    layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          //自定义验证规则
          alert($.ajax);
          //监听提交
          form.on('submit(modify)', function(data){
            console.log(data);
            //alert($("#rates").val());
            try{
            var d= JSON.parse($("#rates").val());
            }catch(e){
            	 layer.msg('格式错误，请按照之前的格式小心修改!',{icon:1,time:1000}); 
            	return false;
            }
            $.post("para/updateRate",{rates:$("#rates").val()},function(data){
            	 layer.msg("添加成功", { icon: 6, time: 2000 });
            }).error(function(){
            	alert("修改失败");
            });
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6},function () {
                // 获得frame索引
               // var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
               // parent.layer.close(index);
            });
            return false;
          });
          
          
        });


     
    </script>
   
  </body>

</html>